package com.markerhub.mapper;

import com.markerhub.entity.CourseLearnUnit;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;


@Mapper
public interface CourseLearnUnitMapper extends BaseMapper<CourseLearnUnit> {
    @Select("SELECT " +
            "    u.*, c.course_name as courseName " +
            "FROM m_course_learn_unit u " +
            "JOIN m_course c ON u.course_id = c.id " +
            "JOIN m_teaching_student_in_class tsic ON c.class_id = tsic.class_id " +
            "WHERE tsic.student_id = #{studentId} " +
            "AND u.status = '1' " +  // 只显示已发布的单元
            "ORDER BY u.id")
    List<Map<String, Object>> selectStudentUnits(@Param("studentId") Integer studentId);
}
